import { View } from "../../../../mvc/core/View";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { PageTool } from "../../../../common/global/PageTool";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { EventName } from "../../../mvc/EventName";
import { MsgManager } from "../../../manager/MsgManager";
import { Language } from "../../../../../extend/language/Language";
import { Cache } from "../../../cache/Cache";
import { ItemData } from "../../../resource/info/ItemData";
import { Alert } from "../../../../../com/mui/controls/Alert";
import { MountSWFPanel } from "../mount/MountSWFPanel";
import { ObjCreate } from "../../common/ObjCreate";
import { GImageBitmap } from "../../../../../com/mui/controls/GImageBitmap";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { FlowerBg } from "../../common/FlowerBg";
import { PublicMessageConfig } from "../../../resource/PublicMessageConfig";
import { GScrollPane } from "../../../../../com/mui/controls/GScrollPane";
import { ScrollPolicy } from "../../../../../fl/controls/ScrollPolicy";
import { GTabBar } from "../../../../../com/mui/controls/GTabBar";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { MuiEvent } from "../../../../../com/mui/events/MuiEvent";
import { TilePanel } from "../../equipment/TilePanel";
import { MountItemCellRenderer } from "../mount/MountItemCellRenderer";
import { ListEvent } from "../../../../../fl/events/ListEvent";
import { PageSelecter } from "../../common/pageSelect/PageSelecter";
import { EquipmentModuleConst } from "../../equipment/data/EquipmentModuleConst";
import { SpMountTip } from "../mount/SpMountTip";
import { MountFeeCostCellRenderer } from "../mount/MountFeeCostCellRenderer";
import { PetProcessBar } from "../../pet/PetProcessBar";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { ToolTipUtil } from "../../common/tooltip/util/ToolTipUtil";
import { EBind } from "../../../../../Message/Public/EBind";
import { DataEvent } from "../../../events/DataEvent";
import { MountUtil } from "../../../scene/mount/MountUtil";
import { ECategory } from "../../../../../Message/Public/ECategory";
import { TodayNotTipUtil } from "../../../../common/TodayNotTipUtil";
import { TodayNoTipsConst } from "../../../../component/gconst/TodayNoTipsConst";
import { SelectNumWindow } from "../../common/SelectNumWindow";
import { MountConfig } from "../../../resource/MountConfig";
import { PulseSharedObject } from "../../player/PulseSharedObject";
import { CheckBoxWin } from "../../common/alertwins/CheckBoxWin";
import { EColor } from "../../../../../Message/Public/EColor";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { MountsCache } from "../../../cache/MountsCache";
import { DateParser } from "../../../../common/tools/DateParser";
import { ClockManager } from "../../../manager/ClockManager";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { GLoadedButton } from "../../../../../com/mui/controls/GLoadedButton";
import { EquipmentType_All } from "../../../../../EquipmentModuleConst/EquipmentType_All";
import { _mountIData } from "../../../../../this/_mountIData";
import { _costItemArr } from "../../../../../this/_costItemArr";
type int = number;
//class MountFeedPanel
    
    export  class MountFeedPanel extends View
    {
        constructor()
        {
            super();
            this._itemsDataProvider = new DataProvider();
            this._pageToolUp = new PageTool([], this._UpPageSize);
            this._itemFeedArr = [];
            this._costItemArr = [];
            this._tfBaseAtrrValueArr = [];
            this._tfBaseAtrrValueArrII = [];
            this._gradeAddValueArr = [];
            this._curItemList = [];
            this.initView();
            Dispatcher.addEventListener(EventName.MountFeedSucess, this.onFeedSucess);
            return;
        }

        protected onReadMemoryBtn(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=null;
            var loc5=false;
            var loc6=0;
            var loc7=false;
            var loc8=0;
            var loc9=null;
            var loc10=0;
            var loc11=null;
            var loc12=0;
            var loc13=0;
            var loc14=0;
            var loc15=false;
            var loc16=0;
            var loc17=null;
            if (this._costItemArr.length >= this._downPageSize) 
            {
                MsgManager.showRollTipsMsg(Language.getString(71353));
                return;
            }
            if (Cache.instance.feedMemory.sever) 
            {
                loc2 = Cache.instance.feedMemory.sever.memorys.concat();
                loc3 = 0;
                while (loc3 < this._costItemArr.length) 
                {
                    loc1 = this._costItemArr[loc3]["itemData"] as ItemData;
                    if (loc2.indexOf(loc1.itemCode) > 0) 
                    {
                        loc2.splice(loc2.indexOf(loc1.itemCode), 1);
                    }
                    ++loc3;
                }
                loc4 = [];
                loc6 = 0;
                while (loc6 < this._itemFeedArr.length) 
                {
                    loc5 = false;
                    loc13 = 0;
                    while (loc13 < this._costItemArr.length) 
                    {
                        if (this._itemFeedArr[loc6].uid == this._costItemArr[loc13]["itemData"].uid) 
                        {
                            loc5 = true;
                            break;
                        }
                        ++loc13;
                    }
                    if (!loc5) 
                    {
                        loc4.push(this._itemFeedArr[loc6]);
                    }
                    ++loc6;
                }
                loc7 = false;
                loc8 = 0;
                while (loc8 < loc4.length) 
                {
                    loc14 = 0;
                    while (loc14 < loc2.length) 
                    {
                        if (Cache.instance.feedMemory.isCanFeedByMemory(loc4[loc8], loc2[loc14])) 
                        {
                            this._costItemArr.push({"itemData": loc4[loc8], "num": loc4[loc8].itemAmount});
                            loc7 = true;
                            this._expFeedTotal = this._expFeedTotal + loc4[loc8].itemInfo.item.mountExp * loc4[loc8].itemAmount;
                            this._txExp.text = this._expFeedTotal.toString();
                            if (this._costItemArr.length >= this._downPageSize) 
                            {
                                break;
                            }
                            break;
                        }
                        ++loc14;
                    }
                    if (this._costItemArr.length >= this._downPageSize) 
                    {
                        break;
                    }
                    ++loc8;
                }
                loc10 = (loc9 = Cache.instance.pack.backPackCache.getItemsByJudge(this.filterActIllustrate)).length;
                loc12 = 0;
                while (loc12 < loc10) 
                {
                    loc11 = loc9[loc12] as ItemData;
                    loc15 = false;
                    if (this._costItemArr.length < this._downPageSize) 
                    {
                        loc15 = false;
                        loc16 = 0;
                        while (loc16 < this._costItemArr.length) 
                        {
                            loc1 = this._costItemArr[loc16]["itemData"] as ItemData;
                            if (loc1.uid == loc11.uid) 
                            {
                                loc15 = true;
                                break;
                            }
                            ++loc16;
                        }
                        if (!loc15) 
                        {
                            loc7 = true;
                            this._expFeedTotal = this._expFeedTotal + loc11.itemInfo.item.mountExp * loc11.itemAmount;
                            this._txExp.text = this._expFeedTotal.toString();
                            loc17 = {"itemData": loc11, "num": loc11.itemAmount};
                            this._costItemArr.push(loc17);
                        }
                    }
                    else 
                    {
                        break;
                    }
                    ++loc12;
                }
                if (loc7) 
                {
                    this._costItemsList.dataProvider = new DataProvider(this._costItemArr);
                    this.onUpPageSelecter(null);
                    MsgManager.showRollTipsMsg(Language.getString(71365));
                }
                else 
                {
                    MsgManager.showRollTipsMsg(Language.getString(71364));
                }
            }
            return;
        }

        /* internal  */goFeed(): void
        {
            var closeAlert: Function;

            var loc1;
            if (this.checkMountIsBind()) 
            {
                closeAlert = (arg1: int): void
                {
                    if (arg1 == Alert.OK) 
                    {
                        onFeedConfirm();
                    }
                    return;
                }
                Alert.show(Language.getString(70050), null, Alert.OK | Alert.CANCEL, null, closeAlert);
            }
            else 
            {
                this.onFeedConfirm();
            }
            return;
        }

        public clear(): void
        {
            var loc2=0;
            this._mountModel.clean();
            this._expBar.setValue(0, 0);
            this._fullBar.setValue(0, 0);
            this._fullBar.toolTipData = "";
            this._txCurFeedLevel.text = "";
            this._txNextFeedLevel.text = "";
            this._txLevelAG.text = "";
            var loc1=this._tfBaseAtrrValueArr.length;
            if (this._tfBaseAtrrValueArr.length > 0 && this._tfBaseAtrrValueArrII.length > 0 && this._gradeAddValueArr.length > 0) 
            {
                loc2 = 0;
                while (loc2 < loc1) 
                {
                    this._tfBaseAtrrValueArr[loc2].text = "";
                    this._tfBaseAtrrValueArrII[loc2].text = "";
                    this._gradeAddValueArr[loc2].text = "";
                    ++loc2;
                }
            }
            return;
        }

        public get mountModel(): MountSWFPanel
        {
            return this._mountModel;
        }

        public set mountModel(arg1: MountSWFPanel)
        {
            this._mountModel = arg1;
            return;
        }

        /* internal  */initView(): void
        {
            var loc1=null;
            var loc7=null;
            var loc10=null;
            var loc11=0;
            var loc12=null;
            var loc13=0;
            var loc16=0;
            var loc17=0;
            var loc18=null;
            var loc19=null;
            var loc20=null;
            var loc21=null;
            var loc22=null;
            this.mouseEnabled = false;
            ObjCreate.createBg(0, 0, 279, 323, this);
            this.addChild(new GImageBitmap(ImagesConst.PetMainBg, 3, 3));
            this._mountModel = new MountSWFPanel();
            this._mountModel.mouseEnabled = false;
            this._mountModel.x = 160;
            this._mountModel.y = 124;
            loc1 = GlobalClass.getBitmap(ImagesConst.Fire);
            loc1.x = 6;
            loc1.y = 2;
            this.addChild(loc1);
            ObjCreate.createBg(7, 166, 139, 24, this, ImagesConst.TileBg);
            ObjCreate.createBg(139, 166, 139, 24, this, ImagesConst.TileBg);
            this._stBmMountCur = ObjCreate.createBitmap("", 8, 171, this);
            this._stBmmountNextGrade = ObjCreate.createBitmap("", 139, 171, this);
            this._stBmMountBaseAtrrI = ObjCreate.createBitmap("", 45, 168, this);
            this._stBmMountBaseAtrrII = ObjCreate.createBitmap("", 181, 168, this);
            ObjCreate.createBg(138, 190, 185, 3, this, ImagesConst.Line).rotation = 90;
            var loc2=ObjCreate.createTextField(Language.getString(70048), 21, 190, 40, 20, this, GlobalStyle.textFormat6);
            var loc3=ObjCreate.createTextField(Language.getString(70048), 159, 190, 40, 20, this, GlobalStyle.textFormatGreen);
            var loc4=ObjCreate.createTextField(Language.getString(70054), 86, 190, 40, 20, this, GlobalStyle.textFormat6);
            var loc5=ObjCreate.createTextField(Language.getString(70054), 227, 190, 40, 20, this, GlobalStyle.textFormatGreen);
            this._txCurFeedLevel = ObjCreate.createTextField("", 62, 190, 33, 24, this, GlobalStyle.textFormat6);
            this._txCurFeedLevel.autoSize = flash.text.TextFormatAlign.CENTER;
            this._txNextFeedLevel = ObjCreate.createTextField("", 200, 190, 33, 24, this, GlobalStyle.textFormat5);
            this._txNextFeedLevel.autoSize = flash.text.TextFormatAlign.CENTER;
            var loc6;
            var loc8=(loc6 = Language.getString(70079).split(",")).length;
            var loc9=0;
            while (loc9 < loc8) 
            {
                loc16 = 210 + 22 * loc9;
                loc17 = 213 + 21 * loc9;
                loc18 = ObjCreate.createGTextField(loc6[loc9], 40, loc16, 40, 20, this);
                loc19 = ObjCreate.createGTextField(loc6[loc9], 151, loc16, 40, 20, this);
                loc20 = ObjCreate.createTextField("", 73, loc16, 50, 20, this, GlobalStyle.textFormat2);
                loc21 = ObjCreate.createTextField("", 185, loc16, 50, 20, this, GlobalStyle.textFormat2);
                loc22 = ObjCreate.createTextField("", 236, loc16, 40, 20, this, GlobalStyle.textFormatGreen);
                (loc7 = GlobalClass.getBitmap(ImagesConst.RangeRaise)).x = 220;
                loc7.y = loc17;
                this.addChild(loc7);
                this._tfBaseAtrrValueArr.push(loc20);
                this._tfBaseAtrrValueArrII.push(loc21);
                this._gradeAddValueArr.push(loc22);
                ++loc9;
            }
            this._spTxt = new FlowerBg(280, 74);
            this._spTxt.y = 326;
            this._txDesc = ObjCreate.createTextField("", 7, 9, 255, 63, this._spTxt);
            this._txDesc.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._txDesc.multiline = true;
            this._txDesc.wordWrap = true;
            this._txDesc.mouseWheelEnabled = false;
            this._txDesc.htmlText = "<textFormat leading=\'5\'>" + PublicMessageConfig.instance.getMountModuleTextByName("MountFeedDesc") + "</textFormat>";
            this.addChild(this._spTxt);
            this._contentPane = new GScrollPane();
            this._contentPane.styleName = "GScrollPane";
            this._contentPane.verticalScrollPolicy = ScrollPolicy.ON;
            this._contentPane.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._contentPane.width = 270;
            this._contentPane.height = 68;
            this._contentPane.x = 3;
            this._contentPane.y = 3;
            this._contentPane.source = this._txDesc;
            this._spTxt.addChild(this._contentPane);
            this._spEquipUp = new FlowerBg(256, 148);
            this._spEquipUp.x = 281;
            this._spEquipUp.y = 20;
            addChild(this._spEquipUp);
            this._tabBarUp = new GTabBar();
            this._tabBarUp.x = 282;
            this._tabBarUp.buttonHeight = 20;
            this._tabBarUp.buttonWidth = 38;
            this._tabBarUp.buttonFilters = [FilterConst.glowFilter];
            this._tabBarUp.dataProvider = this._tabBarArr;
            this._tabBarUp.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, this.onTabBarChange);
            addChild(this._tabBarUp);
            this._bmUp = ObjCreate.createBitmap("", 470, 0, this);
            this.addChild(this._mountModel);
            loc11 = 0;
            while (loc11 < this._UpPageSize) 
            {
                (loc10 = GlobalClass.getBitmap(ImagesConst.PackItemBg)).width = 38;
                loc10.height = 38;
                this._spEquipUp.addChild(loc10);
                loc10.x = 7 + loc11 % 6 * 41;
                loc10.y = 3 + Math.floor(loc11 / 6) * 41;
                ++loc11;
            }
            this._itemsList = new TilePanel();
            this._itemsList.verticalGap = 3;
            this._itemsList.horizontalGap = 3;
            this._itemsList.columnWidth = 38;
            this._itemsList.rowHeight = 38;
            this._itemsList.setSize(246, 122);
            this._itemsList.setStyle("cellRenderer", MountItemCellRenderer);
            this._itemsList.move(5, 1);
            this._itemsList.addEventListener(ListEvent.ITEM_CLICK, this.onItemClickHandler);
            this._itemsList.addEventListener(ListEvent.ITEM_DOUBLE_CLICK, this.onItemDbClickHandler);
            this._spEquipUp.addChild(this._itemsList);
            this._pageSelectedBarUp = new PageSelecter();
            this._pageSelectedBarUp.mode = PageSelecter.CompleteMode;
            this._pageSelectedBarUp.move(70, 124);
            this._pageSelectedBarUp.addEventListener(flash.events.Event.CHANGE, this.onUpPageSelecter);
            this._spEquipUp.addChild(this._pageSelectedBarUp);
            this._itemFeedArr = Cache.instance.pack.mountsPackCache.getItemMountCanFeed();
            this._pageToolUp.array = this._itemFeedArr;
            this._pageSelectedBarUp.maxPage = this._pageToolUp.pagesCount;
            this.onUpPageSelecter(null);
            this._spEquipDown = new FlowerBg(255, 211);
            this._spEquipDown.x = 281;
            this._spEquipDown.y = 191;
            addChild(this._spEquipDown);
            this._tabBarDown = new GTabBar();
            this._tabBarDown.x = 282;
            this._tabBarDown.y = 172;
            this._tabBarDown.buttonHeight = 20;
            this._tabBarDown.buttonWidth = 38;
            this._tabBarDown.buttonFilters = [FilterConst.glowFilter];
            this._tabBarDown.dataProvider = [{"name":"", "type": EquipmentType_All, "label": Language.getString(70017)}];
            addChild(this._tabBarDown);
            this._bmGetExp = ObjCreate.createBitmap("", 333, 173, this);
            this._spMountTip = new SpMountTip();
            this._spMountTip.x = 211;
            this._spMountTip.y = 153;
            this._spEquipDown.addChild(this._spMountTip);
            loc13 = 0;
            while (loc13 < this._UpPageSize) 
            {
                (loc12 = GlobalClass.getBitmap(ImagesConst.PackItemBg)).width = 38;
                loc12.height = 38;
                this._spEquipDown.addChild(loc12);
                loc12.x = 7 + loc13 % 6 * 41;
                loc12.y = 3 + Math.floor(loc13 / 6) * 41;
                ++loc13;
            }
            this._costItemsList = new TilePanel();
            this._costItemsList.scrollPolicy = ScrollPolicy.OFF;
            this._costItemsList.verticalGap = 3;
            this._costItemsList.horizontalGap = 3;
            this._costItemsList.columnWidth = 38;
            this._costItemsList.rowHeight = 38;
            this._costItemsList.setSize(246, 120);
            this._costItemsList.setStyle("cellRenderer", MountFeeCostCellRenderer);
            this._costItemsList.addEventListener(ListEvent.ITEM_CLICK, this.onCostItemClickHander);
            this._costItemsList.move(5, 1);
            this._spEquipDown.addChild(this._costItemsList);
            var loc14=ObjCreate.createTextField(Language.getString(70028), 6, 130, 55, 20, this._spEquipDown);
            this._expBar = new PetProcessBar(ImagesConst.GreenBar10, 154, 12);
            this._expBar.move(50, 134);
            this._expBar.setValue(0, 0);
            this._spEquipDown.addChild(this._expBar);
            var loc15=ObjCreate.createTextField(Language.getString(70081), 3, 152, 55, 20, this._spEquipDown);
            this._fullBar = new PetProcessBar(ImagesConst.GreenBar10, 154, 12);
            this._fullBar.move(50, 158);
            this._fullBar.setValue(0, 0);
            this._fullBar.toolTipData = "";
            this._spEquipDown.addChild(this._fullBar);
            this._btnFeed = ObjCreate.createGButton(Language.getString(70016), 93, 182, 72, 22, this._spEquipDown, "ButtonRedMini");
            this._btnFeed.addEventListener(flash.events.MouseEvent.CLICK, this.onFeedClickHandler);
            this._setLink = ObjCreate.createGTextField("", this._btnFeed.x + this._btnFeed.width + 2, this._btnFeed.y + 2, 100, 20, this._spEquipDown);
            this._setLink.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._setLink.htmlText = HTMLUtil.addColor("<a href=\'event:\'><u>" + Language.getString(71361) + "</u></a>", GlobalStyle.color2);
            this._setLink.addEventListener(flash.events.TextEvent.LINK, this.onSetLinkClick);
            this._txExp = ObjCreate.createTextField("0", 433, 168, 92, 40, this, new GTextFormat(FontUtil.stXingkaiName, 24, 15788607));
            this._txLevelAG = ObjCreate.createTextField("", 212, 130, 36, 20, this._spEquipDown, GlobalStyle.textFormat6);
            LoaderHelp.addResCallBack(ResFileConst.mount, this.onLoadBmResource);
            this._readMemoryBtn = ObjCreate.createGButton(Language.getString(71352), 12, 182, 72, 22, this._spEquipDown, "ButtonRedMini");
            this._readMemoryBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onReadMemoryBtn);
            this._readMemoryBtn.toolTipData = Language.getString(71351);
            return;
        }

        /* internal  */filterActIllustrate(arg1: ItemData): Boolean
        {
            var loc1=false;
            if (ToolTipUtil.isActiveIllustrateByItemdata(arg1) && arg1.itemInfo.item.bind == EBind._EBindYes) 
            {
                loc1 = true;
            }
            return loc1;
        }

        /* internal  */onSetLinkClick(arg1): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.FeedMemoryModuleShow, 1));
            return;
        }

        protected onTabBarChange(arg1: Object /* flash.events.Event */): void
        {
            var loc1=arg1.target.selectedIndex;
            this._pageToolUp.array = MountUtil.getTabFeedArray(loc1, this._itemFeedArr);
            this._pageSelectedBarUp.maxPage = this._pageToolUp.pagesCount;
            this._pageSelectedBarUp.currentPage = 1;
            this.onUpPageSelecter(null);
            return;
        }

        protected onItemDbClickHandler(arg1: ListEvent): void
        {
            if (this._costItemArr.length >= this._downPageSize) 
            {
                return;
            }
            var loc1=arg1.item as ItemData;
            this.double_b = true;
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._stBmMountCur.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountCur);
            this._stBmmountNextGrade.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountNextGrade);
            this._stBmMountBaseAtrrI.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountBaseAtrr);
            this._stBmMountBaseAtrrII.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountBaseAtrr);
            this._bmUp.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountCurMaterial);
            this._bmGetExp.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountGetExp);
            return;
        }

        protected onCostItemClickHander(arg1: ListEvent): void
        {
            var loc5=0;
            var loc6=null;
            var loc1=arg1.item;
            var loc2=loc1["itemData"] as ItemData;
            var loc3=loc1["num"] as int;
            var loc4;
            if ((loc4 = this._costItemArr.length) > 0) 
            {
                loc5 = 0;
                while (loc5 < loc4) 
                {
                    loc6 = this._costItemArr[loc5]["itemData"] as ItemData;
                    if (loc2.uid == loc6.uid) 
                    {
                        this._expFeedTotal = this._expFeedTotal - loc2.itemInfo.item.mountExp * loc3;
                        this._txExp.text = this._expFeedTotal.toString();
                        this._costItemArr.splice(loc5, 1);
                    }
                    ++loc5;
                }
            }
            this._costItemsList.dataProvider = new DataProvider(this._costItemArr);
            this.onUpPageSelecter(null);
            return;
        }

        public updateCostItem(arg1: Array<any>): void
        {
            var loc2=false;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=0;
            var loc7=null;
            var loc8=null;
            var loc9=0;
            var loc10=0;
            var loc11=0;
            if (arg1.length == 0) 
            {
                this._costItemArr = [];
                this._costItemsList.dataProvider = new DataProvider(this._costItemArr);
                this.onUpPageSelecter(null);
                return;
            }
            var loc1=[];
            if (arg1.length > 0 && this._costItemArr.length > 0) 
            {
                loc5 = 0;
                while (loc5 < this._costItemArr.length) 
                {
                    loc2 = false;
                    loc3 = this._costItemArr[loc5] as Object;
                    loc6 = 0;
                    while (loc6 < arg1.length) 
                    {
                        loc4 = arg1[loc6];
                        if (loc3["itemData"].uid == loc4.uid && loc3["num"] <= loc4.itemAmount) 
                        {
                            loc2 = true;
                            break;
                        }
                        ++loc6;
                    }
                    if (!loc2) 
                    {
                        loc1.push(loc3);
                    }
                    ++loc5;
                }
                if (loc1.length > 0) 
                {
                    loc10 = 0;
                    while (loc10 < loc1.length) 
                    {
                        loc7 = loc1[loc10]["itemData"] as ItemData;
                        loc11 = 0;
                        while (loc11 < this._costItemArr.length) 
                        {
                            loc8 = this._costItemArr[loc11]["itemData"] as ItemData;
                            loc9 = this._costItemArr[loc11]["num"];
                            if (loc7.uid == loc8.uid) 
                            {
                                this._expFeedTotal = this._expFeedTotal - loc7.itemInfo.item.mountExp * loc9;
                                this._txExp.text = this._expFeedTotal.toString();
                                this._costItemArr.splice(loc11, 1);
                                break;
                            }
                            ++loc11;
                        }
                        ++loc10;
                    }
                    this._costItemsList.dataProvider = new DataProvider(this._costItemArr);
                    this.onUpPageSelecter(null);
                }
            }
            return;
        }

        protected onUpPageSelecter(arg1: Object /* flash.events.Event */): void
        {
            var loc1=this._pageSelectedBarUp.currentPage;
            this.updateItemList(this._pageToolUp.getByPageNo(loc1));
            return;
        }

        /* internal  */updateItemList(arg1: Array<any>): void
        {
            var loc4=null;
            var loc7=null;
            var loc8=0;
            this._itemsDataProvider.removeAll();
            var loc1=arg1.length;
            var loc2=this._costItemArr.length;
            var loc3=0;
            while (loc3 < loc1) 
            {
                arg1[loc3].mountEffect = "";
                ++loc3;
            }
            var loc5=0;
            while (loc5 < loc2) 
            {
                loc4 = this._costItemArr[loc5]["itemData"] as ItemData;
                loc8 = 0;
                while (loc8 < loc1) 
                {
                    loc7 = arg1[loc8] as ItemData;
                    if (loc4.uid == loc7.uid) 
                    {
                        loc7.mountEffect = loc7.uid;
                        break;
                    }
                    ++loc8;
                }
                ++loc5;
            }
            var loc6=0;
            while (loc6 < loc1) 
            {
                this._itemsDataProvider.addItem(arg1[loc6]);
                ++loc6;
            }
            this._itemsList.dataProvider = this._itemsDataProvider;
            return;
        }

        protected onItemClickHandler(arg1: ListEvent): void
        {
            var e: ListEvent;
            var itemData: ItemData;
            var tips: string;
            var callBack: Function;

            var loc1;
            itemData = null;
            tips = null;
            e = arg1;
            if (this._costItemArr.length >= this._downPageSize) 
            {
                return;
            }
            itemData = e.item as ItemData;
            this.double_b = false;
            if (itemData.category == ECategory._ECategoryIllustrate && !ToolTipUtil.isActiveIllustrateByItemdata(itemData)) 
            {
                callBack = (): void
                {
                    flash.utils.setTimeout(dealClick, 260, itemData);
                    return;
                }
                tips = Language.getStringByParam(70283, itemData.htmlName);
                TodayNotTipUtil.toDayNotTip(TodayNoTipsConst.MountIllustrateFeedTips, callBack, tips, null, Alert.OK | Alert.CANCEL);
            }
            else 
            {
                flash.utils.setTimeout(this.dealClick, 260, itemData);
            }
            return;
        }

        /* internal  */dealClick(): void
        {
            var loc1=null;
            if (this.double_b) 
            {
                if (arguments[0] && this.isInCostItemsDataProvider(arguments[0]) == false) 
                {
                    loc1 = {"itemData": arguments[0], "num": arguments[0].itemAmount};
                    this._costItemArr.push(loc1);
                    this._expFeedTotal = this._expFeedTotal + arguments[0].itemInfo.item.mountExp * arguments[0].itemAmount;
                    this._txExp.text = this._expFeedTotal.toString();
                }
                this._costItemsList.dataProvider = new DataProvider(this._costItemArr);
                this.onUpPageSelecter(null);
            }
            else 
            {
                this.realItemClickHandler(arguments[0]);
            }
            return;
        }

        /* internal  */realItemClickHandler(arg1: ItemData): void
        {
            var loc1=null;
            var loc2=null;
            if (arg1 && this.isInCostItemsDataProvider(arg1) == false) 
            {
                if (arg1.itemAmount > 1) 
                {
                    if (this._selectNumWindow == null) 
                    {
                        this._selectNumWindow = new SelectNumWindow();
                    }
                    this._selectNumWindow.updateByItemData(arg1, this.onSelectNumOkHandler);
                    this._selectNumWindow.show();
                    loc2 = this.localToGlobal(new Object /* flash.geom.Point */(mouseX, mouseY));
                    this._selectNumWindow.x = loc2.x - this._selectNumWindow.btnOK.x;
                    this._selectNumWindow.y = loc2.y - this._selectNumWindow.btnOK.y;
                    return;
                }
                this._expFeedTotal = this._expFeedTotal + arg1.itemInfo.item.mountExp;
                this._txExp.text = this._expFeedTotal.toString();
                loc1 = {"itemData": arg1, "num": arg1.itemAmount};
                this._costItemArr.push(loc1);
                this._costItemsList.dataProvider = new DataProvider(this._costItemArr);
                this.onUpPageSelecter(null);
            }
            this._costItemsList.dataProvider = new DataProvider(this._costItemArr);
            return;
        }

        /* internal  */onSelectNumOkHandler(arg1: ItemData, arg2: int): void
        {
            var loc1={"itemData": arg1, "num": arg2};
            this._costItemArr.push(loc1);
            this._expFeedTotal = this._expFeedTotal + arg1.itemInfo.item.mountExp * arg2;
            this._txExp.text = this._expFeedTotal.toString();
            this._costItemsList.dataProvider = new DataProvider(this._costItemArr);
            this.onUpPageSelecter(null);
            return;
        }

        /* internal  */isInCostItemsDataProvider(arg1: ItemData): Boolean
        {
            var loc1=null;
            var loc2=this._costItemArr.length;
            var loc3=0;
            while (loc3 < loc2) 
            {
                loc1 = this._costItemArr[loc3]["itemData"] as ItemData;
                if (loc1.uid == arg1.uid) 
                {
                    return true;
                }
                ++loc3;
            }
            return false;
        }

        protected onFeedClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc3=0;
            var loc4=NaN;
            var loc5=0;
            var loc6=0;
            var loc7=0;
            var loc8=0;
            var loc9=false;
            var loc10=NaN;
            var loc11=0;
            var loc12=false;
            var loc13=false;
            var loc14=false;
            if (!this._mountIData) 
            {
                MsgManager.showRollTipsMsg(Language.getString(70102));
                return;
            }
            if (MountConfig.instance.isDtModel(this._mountIData.modelId) || Cache.instance.pack.mountsPackCache.isTimeliness(this._mountIData)) 
            {
                MsgManager.showRollTipsMsg(Language.getString(70264));
                return;
            }
            var loc1=Cache.instance.role.entityInfo.level;
            var loc2=this._mountIData.itemExInfo.feed_degree;
            if (this._costItemArr.length > 0) 
            {
                if (this.curFull <= 100) 
                {
                    loc4 = 0;
                    loc5 = this._mountIData.itemExInfo.mount_level;
                    loc6 = this._mountIData.itemExInfo.experience;
                    loc7 = this._expFeedTotal;
                    loc9 = false;
                    while (loc7 > 0) 
                    {
                        loc10 = MountConfig.instance.getTotalExpByLevel(loc5 + this._mountIData.itemExInfo.mount_rein * 1000);
                        if (loc7 > loc10) 
                        {
                            loc3 = loc10;
                        }
                        else 
                        {
                            loc3 = loc7;
                        }
                        loc11 = MountConfig.instance.getExpPerDegree(loc5 + this._mountIData.itemExInfo.mount_rein * 1000);
                        loc4 = loc4 + loc3 / loc11;
                        loc7 = loc7 - loc3;
                        if (loc4 + this.curFull >= 100 && !loc9) 
                        {
                            loc9 = true;
                            loc8 = this._expFeedTotal - loc7;
                        }
                        ++loc5;
                        if (!(loc5 > 100)) 
                        {
                            continue;
                        }
                        break;
                    }
                    if (loc4 + this.curFull >= 100) 
                    {
                        if (loc12 = !PulseSharedObject.isTodayNotTips("full100")) 
                        {
                            Alert.alertWinRenderer = CheckBoxWin;
                            Alert.show(Language.getStringByParam(70071, loc8), null, Alert.OK | Alert.CANCEL, null, this.onBtnClickHandlerI);
                        }
                        else 
                        {
                            this.goFeed();
                        }
                    }
                    else 
                    {
                        this.goFeed();
                    }
                }
                else if (this.curFull > 100 && this.curFull <= 119) 
                {
                    if (loc13 = !PulseSharedObject.isTodayNotTips("full100119")) 
                    {
                        Alert.alertWinRenderer = CheckBoxWin;
                        Alert.show(Language.getString(70072), null, Alert.OK | Alert.CANCEL, null, this.onBtnClickHandlerII);
                    }
                    else 
                    {
                        this.goFeed();
                    }
                }
                else if (this.curFull == 120) 
                {
                    if (loc14 = !PulseSharedObject.isTodayNotTips("full120")) 
                    {
                        Alert.alertWinRenderer = CheckBoxWin;
                        Alert.show(Language.getString(70073), null, Alert.OK | Alert.CANCEL, null, this.onBtnClickHandlerIII);
                    }
                    else 
                    {
                        this.goFeed();
                    }
                }
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(70052));
            }
            return;
        }

        /* internal  */onBtnClickHandlerI(arg1: int, arg2: Boolean): void
        {
            if (arg1 == Alert.OK) 
            {
                Alert.resetToDefault();
                this.goFeed();
            }
            if (arg2) 
            {
                PulseSharedObject.save("full100", true);
            }
            return;
        }

        /* internal  */onBtnClickHandlerII(arg1: int, arg2: Boolean): void
        {
            if (arg1 == Alert.OK) 
            {
                Alert.resetToDefault();
                this.goFeed();
            }
            if (arg2) 
            {
                PulseSharedObject.save("full100119", true);
            }
            return;
        }

        /* internal  */onBtnClickHandlerIII(arg1: int, arg2: Boolean): void
        {
            if (arg1 == Alert.OK) 
            {
                Alert.resetToDefault();
                this.goFeed();
            }
            if (arg2) 
            {
                PulseSharedObject.save("full120", true);
            }
            return;
        }

        /* internal  */onFeedConfirm(): void
        {
            var isNeedAlert: Boolean;
            var onBtnClickHandler: Function;

            var loc1;
            isNeedAlert = false;
            if (this.checkItemColor()) 
            {
                isNeedAlert = !PulseSharedObject.isTodayNotTips("mountFeedOverPurple");
                if (isNeedAlert) 
                {
                    onBtnClickHandler = (arg1: int, arg2: Boolean): void
                    {
                        if (arg1 == Alert.OK) 
                        {
                            Alert.resetToDefault();
                            finalFeedConfirm();
                        }
                        if (arg2) 
                        {
                            PulseSharedObject.save("mountFeedOverPurple", true);
                        }
                        return;
                    }
                    Alert.alertWinRenderer = CheckBoxWin;
                    Alert.show(Language.getString(70153), null, Alert.OK | Alert.CANCEL, null, onBtnClickHandler);
                }
                else 
                {
                    this.finalFeedConfirm();
                }
            }
            else 
            {
                this.finalFeedConfirm();
            }
            return;
        }

        /* internal  */finalFeedConfirm(): void
        {
            var loc1=null;
            var loc2=0;
            var loc5=0;
            var loc3=this._costItemArr.length;
            var loc4=new Map<any, any> /* flash.utils.Dictionary */();
            if (loc3 > 0) 
            {
                loc5 = 0;
                while (loc5 < loc3) 
                {
                    loc1 = this._costItemArr[loc5]["itemData"] as ItemData;
                    loc2 = this._costItemArr[loc5]["num"] as int;
                    loc4[loc1.uid] = loc2;
                    ++loc5;
                }
                Dispatcher.dispatchEvent(new DataEvent(EventName.MountFeedButtonClick, {"mountIData": _mountIData, "items": _costItemArr}));
            }
            return;
        }

        /* internal  */checkItemColor(): Boolean
        {
            var loc2=false;
            var loc3=null;
            var loc4=0;
            var loc1=this._costItemArr.length;
            if (loc1 > 0) 
            {
                loc2 = false;
                loc4 = 0;
                while (loc4 < loc1) 
                {
                    loc3 = this._costItemArr[loc4].itemData;
                    if (loc3.itemInfo.item.color >= EColor._EColorPurple) 
                    {
                        loc2 = true;
                    }
                    ++loc4;
                }
            }
            return loc2;
        }

        /* internal  */checkMountIsBind(): Boolean
        {
            var loc2=false;
            var loc3=null;
            var loc4=0;
            var loc1=this._costItemArr.length;
            if (loc1 > 0) 
            {
                loc2 = false;
                loc4 = 0;
                while (loc4 < loc1) 
                {
                    loc3 = this._costItemArr[loc4].itemData;
                    loc2 = ItemsUtil.isBind(loc3);
                    ++loc4;
                }
            }
            if (!(ItemsUtil.isBind(this._mountIData) == EBind._EBindYes) && loc2) 
            {
                return true;
            }
            return false;
        }

        public updateInfo(arg1: ItemData): void
        {
            this._mountIData = arg1;
            if (this._mountIData) 
            {
                this.updateSwf();
            }
            else 
            {
                this.clear();
            }
            return;
        }

        public updateItemFeed(arg1: Array<any>): void
        {
            if (arg1) 
            {
                this._itemFeedArr = arg1;
                this._pageToolUp.array = MountUtil.getTabFeedArray(this._tabBarUp.selectedIndex, this._itemFeedArr);
                this._pageSelectedBarUp.maxPage = this._pageToolUp.pagesCount;
                this.onUpPageSelecter(null);
            }
            return;
        }

        /* internal  */updateSwf(): void
        {
            var loc1=0;
            var loc2=NaN;
            var loc3=NaN;
            var loc4=null;
            var loc5=null;
            var loc6=0;
            var loc7=null;
            var loc8=0;
            var loc9=0;
            var loc10=null;
            var loc11=null;
            if (this._mountIData) 
            {
                this._mountModel.updateModelByCode(this._mountIData);
                loc1 = this._mountIData.itemExInfo.mount_level;
                loc2 = this._mountIData.itemExInfo.experience;
                this.curFull = this._mountIData.itemExInfo.feed_degree;
                loc3 = MountConfig.instance.getTotalExpByLevel(loc1 + this._mountIData.itemExInfo.mount_rein * 1000);
                this._expBar.setValue(loc2, loc3);
                this._txLevelAG.text = loc1.toString() + Language.getString(70054);
                this._spMountTip.updateInfo(this._mountIData);
                if (this.curFull >= 100 && this.curFull <= 119) 
                {
                    this._fullBar.progressBarClass = ImagesConst.PurpleBar10;
                    this._fullBar.toolTipData = Language.getStringByParam(70086, MountsCache.FULL50);
                }
                else if (this.curFull != 120) 
                {
                    this._fullBar.progressBarClass = ImagesConst.GreenBar10;
                    this._fullBar.toolTipData = Language.getStringByParam(70086, MountsCache.FULL100);
                }
                else 
                {
                    this._fullBar.progressBarClass = ImagesConst.RedBar10;
                    this._fullBar.toolTipData = Language.getStringByParam(70086, MountsCache.FULL25);
                }
                this._fullBar.setValue(this.curFull, 120);
                this._txCurFeedLevel.text = this._mountIData.itemExInfo.mount_level.toString();
                loc4 = Cache.instance.pack.mountsPackCache.getAllUpgradeBaseAttrValue(this._mountIData, this._mountIData.itemExInfo.m_adv_lv);
                loc5 = Cache.instance.pack.mountsPackCache.getAllUpgradeBaseAttrValue(this._mountIData, this._mountIData.itemExInfo.m_adv_lv, true);
                loc6 = this._tfBaseAtrrValueArr.length;
                loc7 = [];
                loc8 = 0;
                while (loc8 < loc4.length) 
                {
                    loc7.push(loc5[loc8] - loc4[loc8]);
                    ++loc8;
                }
                loc9 = 0;
                while (loc9 < loc6) 
                {
                    this._tfBaseAtrrValueArr[loc9].text = loc4[loc9];
                    this._tfBaseAtrrValueArrII[loc9].text = loc5[loc9];
                    this._gradeAddValueArr[loc9].text = loc7[loc9];
                    ++loc9;
                }
                if (loc1 < 100) 
                {
                    this._txNextFeedLevel.text = (this._mountIData.itemExInfo.mount_level + 1).toString();
                }
                else 
                {
                    this._txNextFeedLevel.text = "1";
                }
                loc10 = DateParser.strToDateNormal(this._mountIData.itemExInfo.l_feed_dt);
                loc11 = ClockManager.instance.nowDate;
                if (!(loc10.getMonth() === loc11.getMonth()) || !(loc10.getFullYear() === loc11.getFullYear()) || !(loc10.getDate() === loc11.getDate())) 
                {
                    this.curFull = 0;
                    this._fullBar.setValue(this.curFull, 120);
                    this._fullBar.toolTipData = Language.getStringByParam(70086, MountsCache.FULL100);
                }
            }
            else 
            {
                this.clear();
                this._spMountTip.updateInfo(this._mountIData);
            }
            return;
        }

        public clearCostList(): void
        {
            this._costItemArr = [];
            this._costItemsList.dataProvider = new DataProvider(this._costItemArr);
            this._expFeedTotal = 0;
            this._txExp.text = this._expFeedTotal.toString();
            this.onUpPageSelecter(null);
            return;
        }

        /* internal  */onFeedSucess(arg1: DataEvent): void
        {
            this.clearCostList();
            return;
        }

        /* internal */ /* const */_tabBarArr: Array<any>=Language.getArray(42507);

        /* internal */ /* var */_txLevelAG: Object /* flash.text.TextField */;

        /* internal */ /* var */curFull: int;

        /* internal */ /* var */_spMountTip: SpMountTip;

        /* internal */ /* var */_stBmMountCur: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_stBmmountNextGrade: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_txDesc: Object /* flash.text.TextField */;

        /* internal */ /* var */_stBmMountBaseAtrrII: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_curItemList: Array<any>;

        /* internal */ /* var */_spInfo: FlowerBg;

        /* internal */ /* var */double_b: Boolean;

        /* internal */ /* var */_setLink: GTextFiled;

        /* internal */ /* var */_readMemoryBtn: GButton;

        /* internal */ /* var */_spTxt: FlowerBg;

        /* internal */ /* var */_spEquipUp: FlowerBg;

        /* internal */ /* var */_spEquipDown: FlowerBg;

        /* internal */ /* var */_stBmMountBaseAtrrI: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_mountModel: MountSWFPanel;

        /* internal */ /* var */_expBar: PetProcessBar;

        /* internal */ /* var */_fullBar: PetProcessBar;

        /* internal */ /* var */_btnLevelUp: GLoadedButton;

        /* internal */ /* var */_btnFeed: GButton;

        /* internal */ /* var */_bmUp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_downPageSize: int=18;

        /* internal */ /* var */_UpPageSize: int=18;

        /* internal */ /* var */_itemsList: TilePanel;

        /* internal */ /* var */_itemsDataProvider: DataProvider;

        /* internal */ /* var */_pageToolUp: PageTool;

        /* internal */ /* var */_costItemsList: TilePanel;

        /* internal */ /* var */_selectNumWindow: SelectNumWindow;

        /* internal */ /* var */_expFeedTotal: int=0;

        /* internal */ /* var */_tabBarUp: GTabBar;

        /* internal */ /* var */_tabBarDown: GTabBar;

        /* internal */ /* var */_pageSelectedBarUp: PageSelecter;

        /* internal */ /* var */_bmGetExp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfBaseAtrrValueArrII: Array<any>;

        /* internal */ /* var */_txExp: Object /* flash.text.TextField */;

        /* internal */ /* var */_txLevel: Object /* flash.text.TextField */;

        /* internal */ /* var */_mountIData: ItemData;

        /* internal */ /* var */_itemFeedArr: Array<any>;

        /* internal */ /* var */_costItemArr: Array<any>;

        /* internal */ /* var */_tfBaseAtrrValueArr: Array<any>;

        /* internal */ /* var */_gradeAddValueArr: Array<any>;

        /* internal */ /* var */_txCurFeedLevel: Object /* flash.text.TextField */;

        /* internal */ /* var */_txNextFeedLevel: Object /* flash.text.TextField */;

        /* internal */ /* var */_contentPane: GScrollPane;
    }
